package com.lyl.goods.config;

import com.lyl.goods.interceptor.AuthInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
 /**
 * @Description: 拦截器注册
 * @Author: Liyunlong
 * @Date: 2024/3/1
 */
    @Autowired
    private AuthInterceptor authInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor)
                .addPathPatterns("/**") // 匹配所有请求
                .excludePathPatterns("/login", "/register"); // 不需要拦截的登录和注册页面
    }
}